package src

import (
 "net/http"
 "encoding/json"
 "io/ioutil"
)

type Response struct {
	Session *string `json:"session_id"`
	ErrorCode int	`json:"errorCode"`
	ErrorMessage string	`json:"errorMessage"`
	Result interface {}	`json:"result"`
}

type Emp struct {
	Auth *AuthObj `json:"auth"`
	Token string `json:"token"`
}

type AuthObj struct {
	Session *string `json:"session_id"`
}

func ParseParams(r *http.Request) (Emp, []byte) {
	body,err :=ioutil.ReadAll(r.Body)
	if err!=nil {
		panic("reading error")
	}
	var emp Emp
	err = json.Unmarshal(body,&emp)
	if err!=nil {
		panic("unmarchalling EMP error")
	}
	
	return emp, body
}